package com.atguigu.day13.work;

public class Tunnel implements Runnable {
    private int crossNum=0;

    @Override
    public void run() {
        cross();
    }
    public synchronized void cross(){
        System.out.println(Thread.currentThread().getName()+"开始通过隧道");
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        crossNum++;
        System.out.println(Thread.currentThread().getName()+"已经通过隧道,是第:"+crossNum+"个通过的");
    }
}
